package com.xcdh.orm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcdh.commons.encrypt.AESCoder;
import com.xcdh.orm.entity.OrmDataSource;
import com.xcdh.orm.mapper.DcmsDataSourceMapper;
import com.xcdh.orm.service.DcmsDataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DcmsDataSourceServiceImpl  extends ServiceImpl<DcmsDataSourceMapper, OrmDataSource> implements DcmsDataSourceService {
    @Autowired
    private DcmsDataSourceMapper dataSourceMapper ;
    @Override
    public int insertDataSource(OrmDataSource dataSource) {
        try {
            dataSource.setPassword(AESCoder.encrypt(dataSource.getPassword()));
            return dataSourceMapper.insert(dataSource);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
